#!/bin/bash

HTTP_OK=$(netstat -nat | grep -i listen | grep 80 | wc -l)
SSL_OK=$(netstat -nat | grep -i listen | grep 443 | wc -l)
LOG=/var/log/apache2/monitor.log


if [ $HTTP_OK -ne 1 -o $SSL_OK -ne 1 ]; then
	echo "$(date +%Y%m%d-%H:%M:%S)" >> $LOG
	/etc/init.d/apache2 start >> $LOG
else
	echo ok
fi

